<?php

namespace StarCloud\Models;

class OperatorLog extends Base
{
    const TYPE_BOSS = 'boss';
    const TYPE_START_CLOUD = 'star_cloud';
    const TYPE_HEALTHY_member = 'healthy_member';
    const TYPE_HEALTHY_doctor = 'healthy_doctor';
    const TYPE_HEALTHY_ADMIN = 'healthy_admin';

    protected $tableName = 'operator_log';

    public static function newLog($uid, $type, $method, $url, $request, $response)
    {
        $log = new self();
        $log->uid = $uid;
        $log->type = $type;
        $log->method = $method;
        $log->url = $url;
        if (is_array($request)) {
            $request = json_encode($request);
        }
        $log->request = $request;
        $log->response = $response;
        $log->save();
    }

    protected $id;
    protected $uid;
    protected $type;
    protected $method;
    protected $url;
    protected $request;
    protected $response;
    protected $created_at;
    protected $updated_at;
}
